<#include "common/main.html">
<#macro bodyId>common-edit</#macro>
<#macro content>


<div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main ty-common-page">
    <h1 class="page-header">发送消息

    </h1>



    <!--<form action="/sendMessage/send" class="form-horizontal" enctype="multipart/form-data" method="post" style="max-width: 930px" id="sendForm">-->
    <form  class="form-horizontal" enctype="multipart/form-data"  style="max-width: 930px" id="sendForm">
        <div class="form-group">

            <label class="col-sm-2 control-label ">手机号</label>
            <div class="col-sm-3">
            <input type="file" id="file" name="file">
            </div>
        </div>


        <div class="form-group">

            <label class="col-sm-2 control-label required">消息类型：</label>
            <div class="col-sm-3">
                <select class="form-control" name="type" id="type">
                    <option value="1">微信服务通知</option>
                    <option value="2">短信</option>
                    <option value="3">内部员工</option>
                    <option value="4">外部有效注册用户</option>
                    <option value="5">内部员工+外部有效注册用户</option>
                </select>
            </div>
        </div>


        <div class="form-group" id="msgDiv1">

            <label class="col-sm-2 control-label required">消息1：</label>

                <textarea  id="message1" name="message1" style="width: 80%;margin-left: 2%;height: 200px"></textarea>

        </div>

        <div class="form-group" id="msgDiv2">

            <label class="col-sm-2 control-label required">消息2：</label>

                <textarea  id="message2"  name="message2" style="width: 80%;margin-left: 2%;height: 200px"></textarea>

        </div>

        <div class="form-group">
            <div class="col-sm-offset-2 col-sm-8">
                <input type="submit" value="发送" class="btn btn-success" onclick="send()" id="sendSubmit">
            </div>
        </div>

    </form>




</div>
<script src="/static/lib/jquery.min.js"></script>
<script >

    $(function () {
        $('#type').change(function(){
            var msgTypeValue = $('#type').val();
            if (msgTypeValue == '1') {
                $('#msgDiv2').show();
            } else {
                $('#msgDiv2').hide();
            }

        });


    });
    
    function send() {
        $('#sendSubmit').attr("disabled",true);
        var form = new FormData(document.getElementById("sendForm"));
        $.ajax({
            url:"/sendMessage/send",
            type:"Post",
            data:form,
            processData:false,
            contentType:false,
            dataType: 'json',
            success:function(data){
                alert(data.msg);
                $('#sendSubmit').attr("disabled",false);
            },
            error:function(data){
                alert(data.msg);
                $('#sendSubmit').attr("disabled",false);

            }
        });
    }


</script>
</#macro>